Resources and Links for Plotly and ggplot2.
Here are the links for the resources mentioned in this lecture:
Package to install:
install.packages('plotly')
Reference for gglotly() examples:
We can use the open source library called ‘plotly’ to convert our ggplot2 graphics into interactive images.
Let’s install the ‘plotly’ library and call all necessary libraries for our project:
# install.packages("plotly")
# call the libraries
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
Let’s create a scatterplot from the ‘mtcars’ built-in dataset.
pl <- ggplot(mtcars,aes(mpg,wt)) + geom_point()
pl
Use ggplotly() to convert the non-interactive plot into an interactive one.
gpl <- ggplotly(pl)
gpl